var body = document.getElementsByTagName('body')[0];
var loader = document.getElementsByClassName('loader')[0];
var remark = document.getElementsByClassName('remark')[0];
var loading = document.getElementsByClassName('loading')[0];
body.style.overflow = 'hidden';


var img = new Image();
img.src = 'src/img/bg.png';
var checkImg = setInterval(onloaded,200);

function onloaded(){

	if(img.complete){
		body.style.backgroundImage = "url(" + img.src + ")";
		clearInterval(checkImg);
		loaded();
	}  
	else{
		console.log('not complete');
	}

}

img.onerror = function(){
	clearInterval(checkImg);
	remark.innerHTML = '图片加载失败';
}

function loaded(){
	remark.innerHTML = '图片加载已完成,1.5s后显示主页';
	setTimeout(function(){
		// loader.style.left = -100 + '%';
		loader.style.opacity = 0;
		setTimeout(function(){
			loading.style.animation = 'none 0';
			loader.style.display = 'none';
		},1000);
	},1500);
}